package com.healthtop.dao;


import com.healthtop.mapper.XsRoleResourceMapper;
import com.healthtop.model.XsRoleResource;
import com.healthtop.model.XsRoleResourceExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public class XsRoleResourceDao {

    @Autowired
    private XsRoleResourceMapper roleResourceMapper;

    public void save(XsRoleResource roleResource) {
        roleResourceMapper.insertSelective(roleResource);
    }

    public List<XsRoleResource> selectByRoleId(Long roleId) {
        XsRoleResourceExample example = new XsRoleResourceExample();
        example.createCriteria().andRidEqualTo(roleId);
        return roleResourceMapper.selectByExample(example);
    }

    public List<XsRoleResource> selectByResourceId(Long resourceId) {
        XsRoleResourceExample example = new XsRoleResourceExample();
        example.createCriteria().andResourceIdEqualTo(resourceId);
        return roleResourceMapper.selectByExample(example);
    }

    public void deleteByRoleId(Long roleId) {
        XsRoleResourceExample example = new XsRoleResourceExample();
        example.createCriteria().andRidEqualTo(roleId);
        roleResourceMapper.deleteByExample(example);
    }

    public void deleteByResourceId(Long resourceId) {
        XsRoleResourceExample example = new XsRoleResourceExample();
        example.createCriteria().andResourceIdEqualTo(resourceId);
        roleResourceMapper.deleteByExample(example);
    }

}
